<?php
/**
 * Created by PhpStorm.
 * User: kkw
 * Date: 2019/1/30
 * Time: 19:21
 */
namespace kkw\user\response;
use kkw\user\table\UserTable;
use kkw\user\Util;
use suda\core\Request;
use suda\core\Response;

class EarnUserResponse extends  Response
{
    public function onRequest(Request $request)
    {
        // 引用头文件
        Util::printHeader();

        // 实例化用户表
        $user = new UserTable();

        // 差选数据
        try {
            $userData= $user->list();
        } catch (\suda\exception\SQLException $e) {
            $this->json(['code'=> $e->getCode(), ',message'=>'查询数据失败']);
        }
        $this->json([
            'code'=> 0,
            'data'=>$userData
        ]);
    }
}